package com.xiyu.service.controller.admin.fee;
import com.xiyu.service.vo.fee.feeRecharge.FeeRechargeSingleGetByElderIdOutput;
import com.xiyu.service.vo.fee.feeRecharge.FeeRechargeCreateInput;
import com.xiyu.service.vo.fee.feeRecharge.FeeRechargePageQueryFlowOutput;
import com.xiyu.service.vo.fee.feeRecharge.FeeRechargePageQueryFlowInput;
import com.xiyu.service.vo.fee.feeRecharge.FeeRechargePageQueryDetailOutput;
import com.xiyu.service.vo.fee.feeRecharge.FeeRechargePageQueryDetailInput;
import com.xiyu.service.vo.fee.feeRecharge.FeeRechargePageQueryOutput;
import com.xiyu.service.vo.fee.feeRecharge.FeeRechargePageQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.fee.FeeRechargeService;

@Tag(name = "预充值费用管理")
@RestController
@RequestMapping("/fee/fee-recharge")
@Validated
public class FeeRechargeController {

    @Resource
    private FeeRechargeService feeRechargeService;

    @GetMapping("/page-query")
    @Operation(summary = "分页查询预充值费用")
    @PreAuthorize("@ss.hasPermission('fee:recharge:query')")
    public CommonResult<PageResult<FeeRechargePageQueryOutput>> pageQuery(@Valid FeeRechargePageQueryInput inputVO) {
        return success(feeRechargeService.pageQuery(inputVO));
    }

    @GetMapping("/page-query-detail")
    @Operation(summary = "分页查询预充值费用详情")
    @PreAuthorize("@ss.hasPermission('fee:recharge:queryDetail')")
    public CommonResult<PageResult<FeeRechargePageQueryDetailOutput>> pageQueryDetail(@Valid FeeRechargePageQueryDetailInput inputVO) {
        return success(feeRechargeService.pageQueryDetail(inputVO));
    }

    @GetMapping("/page-query-flow")
    @Operation(summary = "分页查询预充值费用流程")
    @PreAuthorize("@ss.hasPermission('fee:recharge:queryFlow')")
    public CommonResult<PageResult<FeeRechargePageQueryFlowOutput>> pageQueryFlow(@Valid FeeRechargePageQueryFlowInput inputVO) {
        return success(feeRechargeService.pageQueryFlow(inputVO));
    }

    @PostMapping("/create")
    @Operation(summary = "预充值")
    @PreAuthorize("@ss.hasPermission('fee:recharge:recharge')")
    public CommonResult<Long> create(@Valid @RequestBody FeeRechargeCreateInput inputVO) {
        return success(feeRechargeService.create(inputVO));
    }

    @PostMapping("/confirm")
    @Operation(summary = "确认缴费")
    @PreAuthorize("@ss.hasPermission('fee:recharge:confirm')")
    @Parameter(name = "id", description = "预充值费用明细主键ID", example = "")
    public CommonResult<Boolean> confirm(@RequestParam("id") Long id) {
        return success(feeRechargeService.confirm(id));
    }

    @GetMapping("/single-get-by-elder-id")
    @Operation(summary = "根据老人ID获取单个预充值费用")
    @Parameter(name = "id", description = "老人基本信息主键ID", example = "")
    public CommonResult<FeeRechargeSingleGetByElderIdOutput> singleGetByElderId(@RequestParam("id") Long id) {
        return success(feeRechargeService.singleGetByElderId(id));
    }

}
